<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Trapezoid Area Calculator</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 600px;
            margin: 0 auto;
            padding: 20px;
        }
        h1 {
            color: #333;
            text-align: center;
        }
        .calculator {
            background-color: #f5f5f5;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .input-group {
            margin-bottom: 15px;
        }
        label {
            display: inline-block;
            width: 80px;
            font-weight: bold;
        }
        input {
            padding: 8px;
            width: 100px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        button {
            background-color: #4CAF50;
            color: white;
            padding: 10px 15px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
        button:hover {
            background-color: #45a049;
        }
        #result {
            margin-top: 20px;
            font-weight: bold;
            font-size: 18px;
        }
    </style>
</head>
<body>
    <h1>自定义函数的应用</h1>
    <div class="calculator">
        <h2>输入数据</h2>
        <div class="input-group">
            <label for="top">上底：</label>
            <input type="number" id="top" value="10">
        </div>
        <div class="input-group">
            <label for="bottom">下底：</label>
            <input type="number" id="bottom" value="15">
        </div>
        <div class="input-group">
            <label for="height">高度：</label>
            <input type="number" id="height" value="10">
        </div>
        <button onclick="calculateArea()">求面积</button>
        <button onclick="showAlert()">显示告警信息</button>
        <div id="result"></div>
    </div>

    <script>
        function calculateArea() {
            // Get input values
            const top = parseFloat(document.getElementById('top').value);
            const bottom = parseFloat(document.getElementById('bottom').value);
            const height = parseFloat(document.getElementById('height').value);
            
            // Calculate trapezoid area
            const area = (top + bottom) * height / 2;
            
            // Display result
            document.getElementById('result').textContent = `梯形面积为 ${area}`;
        }
        
        function showAlert() {
            alert("单击按钮，弹出告警信息框");
        }
    </script>
</body>
</html>